﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace JavaSubstitutes
{
	public static class ListExtensions
	{
		public static void add<T>(this List<T> list, T toAdd)
		{
			list.Add(toAdd);
		}

		public static void clear<T>(this List<T> list)
		{
			list.Clear();
		}

		public static bool addAll<T>(this List<T> list, int indexToAddTo, List<T> toAdd)
		{
			//http://download.oracle.com/javase/6/docs/api/java/util/List.html#addAll%28int,%20java.util.Collection%29

			for (int i = toAdd.Count - 1; i >= 0; i--)
			{
				list.Insert(indexToAddTo, toAdd[i]);
			}

			return true; //do we care to precisely mimic the java addAll return value?=			
		}

		public static bool removeAll<T>(this List<T> list, List<T> toRemove)
		{
			foreach (T item in toRemove)			
			{
				list.Remove(item);
			}

			return true; //it shouldn't always be true, but do we care?
		}
	}
}
